{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "62338218",
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "\n",
    "# 支持中文\n",
    "plt.rcParams['font.sans-serif'] = ['SimHei']  # 用来正常显示中文标签\n",
    "plt.rcParams['axes.unicode_minus'] = False  # 用来正常显示负号\n",
    "\n",
    "\n",
    "\n",
    "class LinearMode1:\n",
    "    def __init__(self):\n",
    "        self.omega = 0\n",
    "        self.b = 0\n",
    "\n",
    "\n",
    "    def fit(self,x_train, y_train):\n",
    "        self.omega = (y_train[0] - y_train[1]) / (x_train[0] - x_train[1])\n",
    "        self.b = y_train[0] - x_train[0] * self.omega\n",
    "\n",
    "\n",
    "    def predict(self, x_train):\n",
    "        y_train = self.omega * x_train + self.b\n",
    "        return y_train"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "a1d235cd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Input x1 y1 x2 y2：1 2 3 4\n"
     ]
    }
   ],
   "source": [
    "lm = LinearMode1()\n",
    "# 获取用户输入\n",
    "x1, y1, x2, y2 = map(eval, input(\"Input x1 y1 x2 y2：\").split())\n",
    "X = [x1, x2]\n",
    "Y = [y1, y2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "8a3750e6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Training result:omega=1.000000,b=1.000000\n",
      "Input x：22\n",
      "Predict result:x=22.00平米,y=23.00万元\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAETCAYAAADZHBoWAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAqMElEQVR4nO3dd5xU1f3/8ddH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apoA9wMvAe8At7j7m2Z2AzDS3edt0Q8lUgMaaBaJRL/IP3H364EWZrbJblflvECYIbRLqrdj42mgsp/RAngSuNjdx5S0R4PP7YD3gIJosHoPJQTJNFUKIlvAzPYE2rn7o+XazyRUCpvsk2tm9dx9bXT/dGAvd7+5XJ+/Ao+6e5U7zomkk5KCiIiU0ukjEREppaQgIiKllBRERKSUkoKIiJRSUhARkVJKCiIiUur/A60957xuWWT7AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 拟合直线\n",
    "lm.fit(X, Y)\n",
    "\n",
    "# 输出拟合结果\n",
    "print(f\"Training result:omega={lm.omega:.6f},b={lm.b:.6f}\")\n",
    "\n",
    "# 获取预测输入\n",
    "x = float(input(\"Input x：\"))\n",
    "y = predict(lm, x)\n",
    "\n",
    "# 输出预测结果\n",
    "print(f\"Predict result:x={x:.2f}平米,y={y:.2f}万元\")\n",
    "\n",
    "# 画图部分\n",
    "x_values = [min(X), max(X)]\n",
    "y_values = [predict(lm, x) for x in x_values]\n",
    "\n",
    "plt.scatter(X, Y, color='red')\n",
    "plt.plot(x_values, y_values, color='blue')\n",
    "plt.xlabel('x (平米)')\n",
    "plt.ylabel('y (万元)')\n",
    "plt.title('Linear Regression')\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "ab442321",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "([1, 3], [2, 4])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X,Y"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
